﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TTIServer
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{


		//ExpressKeySettings mySettings;
		StylusPointDescription penDescription;
		ExpressKeySettings ExpressKeysToModify;
		public MainWindow( ExpressKeySettings inExpressKeys)
		{
			InitializeComponent();
			this.Visibility = Visibility.Hidden;

			//mySettings = inSettings;

			////List<ExpressKeyAction> tempList = mySettings.GetActionItems();

			//for (int i = 0; i < tempList.Count; i++)
			//comboBox.Items.Add(tempList[i].ActionDescription);

			StylusInAirMove += MainWindow_StylusInAirMove;

			penDescription = new StylusPointDescription(new StylusPointPropertyInfo[] {

					    new StylusPointPropertyInfo(StylusPointProperties.X),
					    new StylusPointPropertyInfo(StylusPointProperties.Y),
					    new StylusPointPropertyInfo(StylusPointProperties.NormalPressure),
					    new StylusPointPropertyInfo(StylusPointProperties.Z),
					    new StylusPointPropertyInfo(StylusPointProperties.XTiltOrientation),
					    new StylusPointPropertyInfo(StylusPointProperties.YTiltOrientation),
					    new StylusPointPropertyInfo(StylusPointProperties.TwistOrientation),
					    new StylusPointPropertyInfo(StylusPointProperties.BarrelButton)
					    

			});

			ExpressKeysToModify = inExpressKeys;

		}

		void MainWindow_StylusInAirMove(object sender, StylusEventArgs e)
		{

			StylusPointDescription wndSPDesc = e.GetStylusPoints(this).Description;
			StylusPointDescription commonDisc = StylusPointDescription.GetCommonDescription(wndSPDesc, penDescription);

			StylusDevice myStylus = e.StylusDevice;
			StylusPointCollection points = myStylus.GetStylusPoints(this, commonDisc);

			textBox.Text = points[0].GetPropertyValue(StylusPointProperties.TwistOrientation).ToString();

		}

		

		protected override void OnClosed(EventArgs e)
		{
			//base.OnClosed(e);
			this.Visibility = Visibility.Hidden;
		}

		private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			// TODO: Add event handler implementation here.
			this.Visibility = Visibility.Hidden;
		}

		private void btnChangeEK_Click(object sender, RoutedEventArgs e)
		{
			ExpressKeySettings.ExpressKey myEK = new ExpressKeySettings.ExpressKey("Change to K", ExpressKeySettings.ExpressKeyActionType.Keystroke, new WindowsInput.VirtualKeyCode[] { WindowsInput.VirtualKeyCode.VK_K } , 1);
			ExpressKeysToModify.changeExpressKeySetting(Treblotto_TabletDefs.ExpressKeyVals.WhichSide.Left, Treblotto_TabletDefs.ExpressKeyVals.ExpressKeys.Button4, myEK);
		}
	}
}
